package com.acerola.protocol.serializer;

import com.alibaba.fastjson2.JSON;

import java.nio.charset.StandardCharsets;

/**
 * @program: Chatting
 * @description: fastjson2序列化
 * @author: Acerola
 * @create: 2022-12-07 14:31
 **/
public class FastJson2 implements Serializer {
    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) {
        return JSON.parseObject(bytes, clazz);
    }

    @Override
    public <T> byte[] serialize(T object) {
        //默认为UTF-8
        return JSON.toJSONBytes(object);
    }
}
